package yz.com.javautil.regex;

/**
 * @author Administrator
 */
public class DealUrlStringUtil {
    public static void main(String[] args) {
        String nameStr = "http://192.168.0.123:123/abc.jpg";
        String nameStr2 = "https://192.168.0.123:123/abc.jpg";
        String nameStr3 = "https://www.baidu.com/abc.jpg";
        System.out.println(dealImageUrl(nameStr, "http://0:5"));
        System.out.println(dealImageUrl(nameStr2, "http://0:5"));
        System.out.println(dealImageUrl(nameStr3, "http://0:5"));
    }

    private static String dealImageUrl(String oldUrl, String newUrl) {
        int index = oldUrl.indexOf("/", 9);
        if (index > 0) {
            String oldPath = oldUrl.substring(index);
            return newUrl + oldPath;
        }else {
            return oldUrl;
        }

    }
}
